#!/usr/bin/env python 3.9
# -*- coding = utr-8 -*-
'''
@Project: Flask
@File: app.py
@IDE: PyCharm
@Author: Simon
@Date: 5/4/21  10:59 AM
'''


from flask import Flask, render_template, request
import sqlite3
import datetime

app = Flask(__name__)

# 开启 Debug 模式
app.config.update(DEBUG=True)


# 路由解析，通过用户访问的路径，匹配相应的函数
@app.route('/')
def index():
    return render_template("index.html")


@app.route('/index')
def home():
    return render_template("index.html")


@app.route('/movie')
def movie():
    datalist = []
    con = sqlite3.connect("movie.db")
    cur = con.cursor()
    sql = "select * from movie250"
    data = cur.execute(sql)
    for item in data:
        datalist.append(item)
    cur.close()
    con.close()

    return render_template("movie.html", movies=datalist)


@app.route('/score')
def score():
    score = []
    num = []
    con = sqlite3.connect("movie.db")
    cur = con.cursor()
    sql = "select score,count(score) from movie250 group by score"
    data = cur.execute(sql)
    for item in data:
        score.append(item[0])
        num.append(item[1])
    cur.close()
    con.close()

    return render_template("score.html", score=score,num=num)


@app.route('/team')
def team():
    return render_template("team.html")


@app.route('/word')
def word():
    return render_template("word.html")


if __name__ == '__main__':
    app.run()

